package cn.itcast.mybatis.dao.impl;

import cn.itcast.mybatis.dao.UserDao;
import cn.itcast.mybatis.pojo.User;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

/**
 * Created by Administrator on 2017/9/3.
 */
public abstract class UserDaoImpl implements UserDao {
    public SqlSession sqlSession;

    public UserDaoImpl(SqlSession sqlSession) {
        this.sqlSession = sqlSession;
    }

    public User queryUserById(Long id) {
        return this.sqlSession.selectOne("UserDaoMapper.queryUserById",id);
    }

    public List<User> queryUserAll() {
        return this.sqlSession.selectList("UserDaoMapper.queryUserAll");
    }

    public void insertUser(User user) {
        this.sqlSession.insert("UserDaoMapper.insertUser",user);
    }

    public void updateUser(User user) {
        this.sqlSession.update("UserDaoMapper.updateUser",user);
    }

    public void deleteUser(Long id) {
        this.sqlSession.delete("UserDaoMapper.deleteUser",id);
    }


}
